import request from '@/utils/request'

// 获取菜单列表
export function getPermissionList() {
  return request({
    url: `/admin/acl/permission`,
    method: 'get'
  })
}

// 根据角色获取菜单列表
export function getPermissionListByRole(roleId) {
  return request({
    url: `/admin/acl/permission/toAssign/${roleId}`,
    method: 'get'
  })
}

// 给角色分配菜单权限
export function assignPermissionByRole(roleId, permissionId) {
  return request({
    url: `/admin/acl/permission/doAssign`,
    method: 'post',
    params: {
      roleId,
      permissionId
    }
  })
}

// 添加菜单
export function savePermission(data) {
  return request({
    url: `/admin/acl/permission/save`,
    method: 'post',
    data
  })
}

// 删除菜单
export function removePermission(id) {
  return request({
    url: `/admin/acl/permission/remove/${id}`,
    method: 'delete'
  })
}
